<?php

/**
* 这个是点赞功能
*/
class ModelDianzan extends GetLoad
{
	
	

	public function getdianzan($name_id){
		$reluse=$this->SQLquery("SELECT * FROM dianzan  where name_id='".$name_id[0]."' order by id desc ");
		//echo "SELECT * FROM dianzan  where name_id='".$name_id[0]."' order by id desc ";
		//var_dump($reluse);
		$this->SQLcun("UPDATE dianzan SET chakan='0' where name_id='".$name_id[0]."'");

		return $reluse;
	}


	public function getinformation($information){
		$reluse=$this->SQLquery("SELECT * from information where information_id=".$information);
		return $reluse[0];

	}

	public function getname($name_id){

		$reluse=$this->SQLquery("SELECT * from name where name_id=".$name_id);
		return $reluse[0];



	}

	public function dianzan($information_id){

		$rusule=$this->SQLquery("SELECT * FROM name where name='".$_COOKIE["name"]."' AND password='".$_COOKIE["password"]."'");
		$name_id=$this->SQLquery("SELECT * FROM information where information_id =".$information_id[0]);
		if($this->panduan($information_id[0],$rusule[0]["name_id"])){
			if($rusule){
				$this->SQLcun("INSERT INTO dianzan (name2_id,name_id,information_id,chakan) VALUES (".$rusule[0]["name_id"].",".$name_id[0]["name_id"].",".$information_id[0].",1)");
				
			}
		}

		header("Location: ./index.php?route=Controller/information/ControllerInformation/index&=".$information_id[0]); 

	}

	public function panduan($information_id,$name_id){
		//echo $information_id,$name_id;die;
		$reluse=$this->SQLquery("SELECT * FROM dianzan where name2_id='".$name_id."' AND information_id='".$information_id."'");
	
		if(!$reluse){

			return 1;
		}else{

			return 0;

		}

	}




}